/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/17
* File: Parameter.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#pragma once

#include "RenderDef.h"
#include "Texture2D.h"

namespace HY
{
class ParameterManager;
class Parameter
{
	friend class ParameterManager;

public:
	enum 
	{
		String			= 0,	/** String */
		Integer			= 1,	/** Integer 1 */
		Integer2		= 2,	/** Integer 2 */
		Integer3		= 3,	/** Integer 3 */
		Integer4		= 4,	/** Integer 4 */
		Float			= 5,	/** Float 1 */
		Float2			= 6,	/** Float 2 */
		Float3			= 7,	/** Float 3 */
		Float4			= 8,	/** Float 4 */
		Float3x3		= 9,	/** Float3x3 matrix */
		Float3x4		= 10,	/** Float3x4 matrix */
		Float4x4		= 11,	/** Float4x4 matrix */
		Texture_2d		= 12,	/** Texture buffer */
		UnknownDataType = 13	/** Unknown data type */
	};
	
public:
	ParameterManager* getParamMgr() const;

	uint32 getType() const;

	const std::string& getName() const;

	void setName(const std::string& name);

	std::string getParamString() const;

	bool setParamString(const std::string& value);

	bool getValue1i(int& x) const;
	bool setValue1i(int x);

	bool getValue2i(int& x, int& y) const;
	bool setValue2i(int x, int y);
	bool setValue2iv(const int* value);

	bool getValue1f(float& x) const;
	bool setValue1f(float x);

	bool getValue2f(float& x, float& y) const;
	bool setValue2f(float x, float y);
	bool setValue2if(const float* value);

	bool getValue3f(float& x, float& y, float& z) const;
	bool setValue3f(float x, float y, float z);
	bool setValue3vf(const float* value);

	bool getValue4f(float& x, float& y, float& z, float& w) const;
	bool setValue4f(float x, float y, float z, float w);
	bool setValue4vf(const float* value);

	bool setValueTexture2D(const std::string& file_name);
	Texture2D* getValueTexture2D() const;

protected:
	Parameter(ParameterManager* mgr, uint32 type, const std::string& name);
	virtual ~Parameter();

protected:
	ParameterManager*	mgr_;
	uint32				type_;
	std::string			name_;
	std::string			param_str_;
	void*				value_;
};
}